package com.example.gcode;

import com.utils.Constants;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class RegisterActivity extends Activity {
	
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.registerlayout);
		
		Button gSignInButton = (Button) findViewById(R.id.buttonRegist);
		gSignInButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Intent intent;
				if (isLoggedIn()) {
					intent = new Intent(RegisterActivity.this, AdminActivity.class);
					startActivity(intent);
				} else {
					intent = new Intent(RegisterActivity.this,
							RegisterActivity.class);
					startActivity(intent);
				}
			}
		});
	}
	
	

	private boolean isLoggedIn() {
		SharedPreferences prefs = getSharedPreferences(
				Constants.gBoxSharedProperties, Context.MODE_PRIVATE);		
			SharedPreferences.Editor editor = prefs.edit();
			editor.putString(Constants.loggedProperty, Constants.trueAnswer);
			editor.commit();			
			return true;		
	}

}
